package com.example.shop.es.xcontent;

import com.example.shop.common.dto.Avatar;
import com.example.shop.es.Writer;
import com.example.shop.goods.dto.Comments;
import com.example.shop.goods.dto.CommentsReply;
import com.example.shop.goods.dto.GoodsStyle;
import com.example.shop.goods.dto.ModifyGoodsStyleParam;
import com.example.shop.user.dto.UserBriefInfo;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderExtension;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

public class GoodsXContentExtend implements XContentBuilderExtension {

    @Override
    public Map<Class<?>, XContentBuilder.Writer> getXContentWriters() {
        HashMap<Class<?>, XContentBuilder.Writer> writerHashMap = new HashMap<>();
        writerHashMap.put(Comments.class, Writer::write);
        writerHashMap.put(CommentsReply.class,Writer::write);
        writerHashMap.put(ModifyGoodsStyleParam.class,Writer::write);
        writerHashMap.put(GoodsStyle.class,Writer::write);
        writerHashMap.put(UserBriefInfo.class,Writer::write);
        writerHashMap.put(Avatar.class,Writer::write);
        return writerHashMap;
    }

    @Override
    public Map<Class<?>, XContentBuilder.HumanReadableTransformer> getXContentHumanReadableTransformers() {
        return new HashMap<>();
    }

    @Override
    public Map<Class<?>, Function<Object, Object>> getDateTransformers() {
        return new HashMap<>();
    }

}
